<template>
  <div class='other-adviser first-box'>
    <MyAdviser :listData="listData" :operateShow="false"></MyAdviser>
    <p class="no-data" v-if="listData.length==0">暂时没有数据</p>
  </div>
</template>
<script>
import MyAdviser from './myadviser.vue'
export default {
  components: {MyAdviser},
  name: "",
  data() {
    return {
      listData:[
        // { 
        //   id:1,
        //   name:"马漂亮",
        //   pic:"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533807483897&di=806e9d941e7ea15c82437d699a42aa7d&imgtype=0&src=http%3A%2F%2Fp2.gexing.com%2FG1%2FM00%2F83%2F4E%2FrBACE1ToAmbz_TgZAAAkpbJV-BU277_200x200_3.jpg%3Frecache%3D20131108",
        //   sex:1,
        //   phone:"12354678999",
        //   wx:"hhda",
        //   type:"1",
        //   click:this.choose,
        //   state:0,//是否选中
        // },{
        //   id:2,
        //   name:"马漂亮",
        //   pic:"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533807483897&di=806e9d941e7ea15c82437d699a42aa7d&imgtype=0&src=http%3A%2F%2Fp2.gexing.com%2FG1%2FM00%2F83%2F4E%2FrBACE1ToAmbz_TgZAAAkpbJV-BU277_200x200_3.jpg%3Frecache%3D20131108",
        //   sex:1,
        //   phone:"12354678999",
        //   wx:"hhda",
        //   type:"1",//顾问类型：1保险顾问；2续保顾问,3保养顾问
        //   click:this.choose,
        //   state:0,//是否选中
        // }
      ],
      imgs:{
        select:{
          noSelected:require('../../../assets/img/hpmepage/renew/choose.png'),
          selected:require('../../../assets/img/hpmepage/renew/choose_1.png')
        }
      }
    };
  },
  methods: {
    getList(){
      var routerParams=_g.getRouterParams(this)

      _g.apiPost("consultants/getAllConsultants.do",{roleName:routerParams.type}).then(res=>{
        if(res.status==1){
          _g.toMessage(res)
          setTimeout(()=>{
            this.$router.go(-1)
          },500)
          return
        }
        var goals=[]
        if(res.data)res.data.forEach(ele=>{
          goals.push({
            id:ele.id,
            name:ele.realName,
            pic:ele.pic||ele.headPic||"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533807483897&di=806e9d941e7ea15c82437d699a42aa7d&imgtype=0&src=http%3A%2F%2Fp2.gexing.com%2FG1%2FM00%2F83%2F4E%2FrBACE1ToAmbz_TgZAAAkpbJV-BU277_200x200_3.jpg%3Frecache%3D20131108",
            sex:ele.sex||1,
            phone:ele.phone,
            type:ele.roleName,
            state:ele.id==routerParams.id,
            click:this.choose,
          })
        })
        this.$set(this,"listData",goals)
      })

      this.listData.forEach(ele=>{
        ele.state=ele.id==routerParams.id?1:0
      })
    },
    choose(info){
      var params={
        // id:sessionStorage.getItem("userId"),
        roleName:info.type,
        employeeId:info.id
      }
      _g.apiPost("consultants/changeMsg.do",params).then(res=>{
        _g.toMessage(res)
        if(res.status==0){
          setTimeout(()=>{
            this.$router.go(-1)
          },500)
        }
      })
      this.listData.forEach(ele=>{
        ele.state=0
      })
      info.state=1
      
    },
  },
  created() {
    this.getList()
  }
};
</script>
<style lang="scss" scoped>
.other-adviser {

}
</style>